﻿<!--#include file="const.inc"-->
<%
dim listid,pageid
		listid=Request.QueryString("listid")
		if not isnumeric(listid) then listid=1
		if listid="" then listid=1
		listid=clng(listid)
		pageid=Request.QueryString("pageid")
		if not isnumeric(pageid) then pageid=1
		if pageid="" then pageid=1
		pageid=clng(pageid)
%>
<!--#include file="abcd.asp"-->
<%
if sid="Null" then
%>
<%=title1%>
	<%=we%>你还没登陆,请先登陆。<%=we0%>
	<%=sou%><a href="/login.asp?sid=<%=sidd%>&amp;url=/bbs/fatie.asp?listid=<%=listid%>">马上登陆</a><%=we0%>

<%
elseif qingtian.qx("noall", listid)=true then
		%>
<%=title2%>
		<%=we%>出错啦!你已被禁止在本论坛发表帖子,有任何问题请联系管理员!<%=we0%>

		<%
else

IF  Request.QueryString("Action")="save" Then
	call save
else
	call index
end if

end if
End Function




Function index
dim listid,pageid
		listid=Request.QueryString("listid")
		if not isnumeric(listid) then listid=1
		if listid="" then listid=1
		listid=clng(listid)
		pageid=Request.QueryString("pageid")
		if not isnumeric(pageid) then pageid=1
		if pageid="" then pageid=1
		pageid=clng(pageid)
%>
<!--#include file="abcd.asp"-->
<%
	dim rs,sql,name,RndTXT,qingt
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "SELECT [name]  FROM [qingtian_bbs] where [del]=0 and [view]=0 and [id]="&listid
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		name=qingtian.utf8(rs("name"))
        else
        qingt=true
	end if
	Rs.close
	Set rs = Nothing
	randomize
	RndTXT=int((99999999)*rnd+1)
%>
<%=title3%>
<%if qingt=true then qingtian.err("该论坛版块不存在")%>
<%=qingtian.qingsav("37")%>
<%if v=0 then %>
	标题:<input emptyok="true"  type="text" maxlength="40" name="name<%=RndTXT%>" size="15"/><br/>
	内容:<input emptyok="true"  type="text" name="content<%=RndTXT%>" size="15"/><br/>
	<anchor>发表新帖
    	<go href="fatie.asp?listid=<%=listid%>&amp;pageid=<%=pageid%>&amp;Action=save&amp;sid=<%=sidd%>" method='post'>
        <postfield name="name" value="$(name<%=RndTXT%>)"/>
        <postfield name="content" value="$(content<%=RndTXT%>)"/>
    	</go>
	</anchor><br/>
<%else%>
<form action="fatie.asp?listid=<%=listid%>&amp;pageid=<%=pageid%>&amp;Action=save&amp;sid=<%=sidd%>" method="post">
<%=we%>标题:<%=we0%>
<input emptyok="true"  type="text" maxlength="40" name="name"" format="*N" size="10"/><br/>
<%=we%>内容:<%=we0%><%=sou%><textarea name="content" rows="4"/><%=rep%></textarea><%=we0%>
<input type="submit" value="发表新帖"/><br/>
</form>
<%end if%>
<%=qingtian.qingsav("36")%><%=we%><a href="upad.asp?listid=<%=listid%>&amp;pageid=<%=pageid%>&amp;sid=<%=sidd%>">发表上传文件帖</a><br/>
<a href="voad.asp?listid=<%=listid%>&amp;pageid=<%=pageid%>&amp;sid=<%=sidd%>">发表投票帖</a><br/>
<%=sou%>
<a href="board.asp?listid=<%=listid%>&amp;page=<%=pageid%>&amp;sid=<%=sidd%>">返回<%=name%></a><%=we0%>

<%
End Function


Function save

dim listid,pageid,id,name
		listid=Request.QueryString("listid")
		if not isnumeric(listid) then listid=0
		if listid="" then listid=0
		listid=clng(listid)
		pageid=Request.QueryString("pageid")
		if not isnumeric(pageid) then pageid=1
		if pageid="" then pageid=1
		pageid=clng(pageid)
		if DATEDIFF("s", session("addtime"), now()) >600 then
		session("addtime")=now
		session("addcount")=0
		end if
		Set Rs = Server.CreateObject("Adodb.Recordset")

	IF len(trim(Request.form("name")))>3 and trim(Request.form("content"))<>""  and session("addBoard")<>trim(Request.form("content")) and session("addcount")<5  then
		dim content,member,rs,nid,ip,sql,zz
		ip=Request.ServerVariables("REMOTE_ADDR")
		name=qingtian.repsql(Request.form("name"))
		content=qingtian.repsql(Request.form("content"))
                faee=qingtian.inlof("faee")
                fae=qingtian.inlof("fae")

		Sql = "select [id],[zf],[money] FROM qingtian_user where [sid]='"&md5(sid) & md5(strReverse(sid))&"'"
		Rs.Open Sql,conn,1,3
		if not (rs.eof and rs.bof) then
			nid=rs("id")
			rs("zf")=rs("zf")+faee
			rs("money")=rs("money")+fae
			rs.update
		else
			nid=0
		end if
		Rs.close


		Sql = "select top 1  [posttime] FROM qingtian_bbs_forum where [content]='"&content&"' and [name]='"&name&"' order by [id] desc"
		Rs.Open Sql,conn,1,1
		if not (rs.eof and rs.bof) then

			if DATEDIFF("s", rs("posttime"), now()) > 60*60 then
			zz=0
			else
			zz=1
			end if
		else
			zz=0
		end if
		Rs.close

		if zz=0 then


		Sql = "select [listid],[name],[content],[nid],[ip] FROM qingtian_bbs_forum"
		Rs.Open Sql,conn,1,3
		rs.addnew
		rs("nid")=nid
		rs("listid")=listid
		rs("name")=name
		rs("content")=content
		rs("ip")=ip
		rs.update
		Rs.close
		Sql = "select [tid] FROM qingtian_bbs  where [id]="&listid&""
		Rs.Open Sql,conn,1,3
		if not (rs.eof and rs.bof) then
		rs("tid")=rs("tid")+1
		rs.update
		end if
		Rs.close

		Sql = "select top 1 [id] from [qingtian_bbs_forum] where nid="&nid&" order by [id] desc"
		Rs.Open Sql,conn,1,1
		if not (rs.eof and rs.bof) then
		id=rs("id")
		end if
		Rs.close
%>
<!--#include file="abcd.asp"-->
<%
		session("addBoard")=content
		if session("addtime")<>"" then
		if DATEDIFF("s", session("addtime"), now()) >20 then
		session("addtime")=now
		session("addcount")=1
		else
		session("addtime")=now
		session("addcount")=session("addcount")+1
		end if
		else
		session("addtime")=now
		session("addcount")=1
		end if
		if session("addcount")>2 then
		%>
<%=title4%><%=qingtian.qingsav("37")%>
<%=we%>你好,请注意一下了..你已经一口气发了<%=session("addcount")%>帖了.<br/><%
		end if
		%>
<%=title6%><%=qingtian.qingsav("37")%>
<%=we%>发表新帖成功.<br/>你的积分增加<%=zi%><%=faee%><%=zi0%>，你的<%=qingtian.bi%>增加<%=zi%><%=fae%><%=zi0%>，今日系统剩余<%=qingtian.bi%>:<%=zi%><%=qingtian.inlof("mot")%><%=zi0%>。<%=we0%><%=sou%>
		<a href="viewv.asp?id=<%=id%>&amp;listid=<%=listid%>&amp;pageid=<%=pageid%>&amp;sid=<%=sidd%>">进入帖子</a><br/>
		<%

		else
		%>
<!--#include file="abcd.asp"-->
<%=title5%><%=we%>请不要发重复的帖!<br/><%
		end if

	else
%>
<!--#include file="abcd.asp"-->
<%=title5%><%=qingtian.qingsav("37")%><%=we%>
		<%if len(trim(Request.form("name")))<4 then%>
		标题不能低于4个字。<br/>
		<%end if%>
		<%if trim(Request.form("name"))="" then%>
		标题不能为空。<br/>
		<%end if%>
		<%if trim(Request.form("content"))="" then%>
		内容不能为空。<br/>
		<%end if%>
		<%if len(Request.form("content"))>0 and session("addBoard")=Request.form("content") then%>
		请不要重复提交。<br/>
		<%end if%>
		<%
		if session("addcount")>4 then
		%>你好,你好你的回复过快..请休息一下在回复,休息时间倒记时:<%=600-DATEDIFF("s", session("addtime"), now())%>秒.<br/><%
		end if
		%>
		<a href="fatie.asp?listid=<%=listid%>&amp;pageid=<%=pageid%>&amp;sid=<%=sidd%>">返回修改</a><br/>
<%	end if

	Sql = "SELECT [name]  FROM [qingtian_bbs] where [del]=0 and [view]=0 and [id]="&listid
	Rs.Open Sql,conn,1,1

	if not (rs.bof and rs.eof)  then
		name=qingtian.utf8(rs("name"))
	end if
	Rs.close
	Set rs = Nothing

%>
-------------<%=we0%><%=qingtian.qingsav("36")%><%=sou%>
<a href="board.asp?listid=<%=listid%>&amp;page=<%=pageid%>&amp;sid=<%=sidd%>">返回<%=name%></a><%=we0%>

<%
end Function 
%>
